<template>
<div class="code_box">
<pre v-highlight>
<code>
    let formData = new FormData()
    for (let k in this.fileData) {
        formData.append(k, this.fileData[k])
    }

    this.$api({
        api: 'api-user-resource-uploadResource',
        data: formData,
        onUploadProgress: (e) => {
           if (e.lengthComputable) {
               var rate = e.loaded / e.total;
               this.upValue = (rate *100).toFixed(2)
           }
        }
    }).then(res => {
        this.upValue = null
        this.$store.commit('setAlert', {
            show: true,
            massage: '上传成功',
            type: 'error',
            time: 2,
        })
        this.$emit('upFile')
    }).catch(err => {
        this.upValue = null
    })
</code>
</pre>
</div>
</template>

<script>
    export default {
        name: "v-tip-fileUp",
        data () {
            return {

            }
        }
    }
</script>

<style scoped src="../style.css"></style>
